package com.ztky.report.controller;

import net.sf.jasperreports.engine.JRException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

/**
 * 健康管理模块报表
 *
 * @author liuji
 */
@Controller
@RequestMapping("/jasper/hms")
public class HmsReportController extends JasperBaseController {
    /**
     * 基础档案
     *
     * @param request
     * @param response
     * @param guestId
     * @throws JRException
     * @throws IOException
     * @throws SQLException
     * @throws ServletException
     */
    @RequestMapping(value = "/basedoc/html")
    public void basedochtml(HttpServletRequest request, HttpServletResponse response, Integer guestId)
            throws ServletException, SQLException, IOException, JRException {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("guestId", guestId);
        super.html(request, response, "hms/hms-doc.jasper", parameters);

    }

    /**
     * 基础档案
     *
     * @param request
     * @param response
     * @param guestId
     * @throws ServletException
     * @throws SQLException
     * @throws IOException
     * @throws JRException
     */
    @RequestMapping(value = "/basedoc/pdf")
    public void basedocpdf(HttpServletRequest request, HttpServletResponse response, Integer guestId)
            throws ServletException, SQLException, IOException, JRException {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("guestId", guestId);
        super.pdf(request, response, "hms/hms-doc.jasper", parameters, "hms-doc-" + guestId + ".pdf");
    }

    /**
     * 基础档案
     *
     * @param request
     * @param response
     * @param guestId
     * @throws ServletException
     * @throws SQLException
     * @throws IOException
     * @throws JRException
     */
    @RequestMapping(value = "/basedoc/word")
    public void basedocword(HttpServletRequest request, HttpServletResponse response, Integer guestId)
            throws ServletException, SQLException, IOException, JRException {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("guestId", guestId);
        super.word(request, response, "hms/hms-doc.jasper", parameters, "hms-doc-" + guestId + ".docx");
    }

}
